<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>时钟</title>
		<script>
			function startTime() {
				var today = new Date();
				var y = today.getFullYear();
				var M = today.getMonth() + 1;
				if(M<10){
					M='0'+M
				}
				var d = today.getDate();
				var h = today.getHours();
				var m = today.getMinutes();
				var s = today.getSeconds(); // 在小于10的数字前加一个‘0’
				var D = today.getDay();
				var weekday = new Array(7);
				weekday[0] = "星期天";
				weekday[1] = "星期一";
				weekday[2] = "星期二";
				weekday[3] = "星期三";
				weekday[4] = "星期四";
				weekday[5] = "星期五";
				weekday[6] = "星期六";
				var xq = weekday[today.getDay()];
				m = checkTime(m);
				s = checkTime(s);
				document.getElementById('txt').innerHTML = '今天是'+y + "年" + M + "月" + d + "日" + xq + ' ' + h + ":" + m + ":" + s;
				document.getElementById('txt1').innerHTML = xq;
				document.getElementById('txt2').innerHTML = h + ":" + m + ":" + s;

				t = setTimeout(function() {
					startTime()
				}, 500);
			}

			function checkTime(i) {
				if (i < 10) {
					i = "0" + i;
				}
				return i;
			}
		</script>
	</head>
	<body onload="startTime()">

		<div id="txt"></div>

		<div id="txt1" >
		</div>
		<div id="txt2">
		</div>
	</body>
</html>
